﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BMLib
{
    public class WaveFileObject
    {
        private List<WaveItem> m_Waves = new List<WaveItem>();
        public List<WaveItem> Waves
        {
            get
            {
                return m_Waves;
            }
            set
            {
                m_Waves = value;
            }
        }

        public string FilePath { get; set; }
        public string FileName
        {
            get
            {
                int n = FilePath.LastIndexOf('\\')+1;
                int c = FilePath.Length - n;
                string r = FilePath.Substring(n, c);
                return r;
            }
        }
        public WaveFileObject()
        { 
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="filepath"></param>
        public void LoadFile(string filepath)
        {
           // HLDrawTools.BeginFile(filepath);


            int param = 0;
            byte[] data = new byte[48016];
            short[] sdata = new short[48016];
            //数据读取
            FileStream file = new FileStream(filepath, FileMode.Open);
            file.Read(data, 0, 4);
            param = BitConverter.ToInt32(data, 0);
            //file.Read(data, 0, 48016);
            for (int i = 0; i < 0xBB90; i++)
            {
                file.Read(data, 0, 2);
                sdata[i] = BitConverter.ToInt16(data, 0);
            }
            file.Close();

            //m_Waves.Add(new WaveItem(3, "左前"));
            //m_Waves.Add(new WaveItem(4, "右前"));
            //m_Waves.Add(new WaveItem(13, "左颞"));
            //m_Waves.Add(new WaveItem(14, "右颞"));
            //m_Waves.Add(new WaveItem(9, "左后"));
            //m_Waves.Add(new WaveItem(10, "右后"));
            m_Waves.Add(new WaveItem(3, param, sdata, "左前"));
            m_Waves.Add(new WaveItem(13, param, sdata, "左颞"));
            m_Waves.Add(new WaveItem(9, param, sdata, "左后"));

            m_Waves.Add(new WaveItem(4, param, sdata, "右前"));
            m_Waves.Add(new WaveItem(14, param, sdata, "右颞"));
            m_Waves.Add(new WaveItem(10, param, sdata, "右后"));
            FilePath = filepath;

        }
    }
}
